package com.dgut.service.serviceImpl;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.stp.StpUtil;
import com.dgut.common.*;
import com.dgut.mapper.InformationPublicityMapper;
import com.dgut.mapper.OrderFlagMapper;
import com.dgut.pojo.InformationPublicity;
import com.dgut.pojo.OrderFlag;
import com.dgut.service.InformationPublicityService;
import com.dgut.service.OrderFlagService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class InformationPublicityServiceImpl implements InformationPublicityService {
    @Resource
    private InformationPublicityMapper informationPublicityMapper;

    @Resource
    private OrderFlagMapper orderFlagMapper;

    /**
     * start-zwb
     */
    //通过id获取工商年报信息
    public Object getInformationPublicity(Integer id)
    {
        return  informationPublicityMapper.selectById(id);
    }
    /**
     * end-zwb
     */


    /**
     * start-gxd
     */
    /**
     * end-gxd
     */


    /**
     * start-lzh
     */
    @Override
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    public Object InsertInformationPublicity(InformationPublicity informationPublicity){//添加信息公示，生成订单
        int insert  = informationPublicityMapper.insert(informationPublicity);
        Object obj= StpUtil.getLoginId();
        Integer id = Integer.parseInt(obj.toString());
        OrderFlag orderFlag = new OrderFlag(id,null, OrderType.INFO_PUBLICITY,informationPublicity.getId(),new Date(),new Date(),new Date(),priceOfOrder.INFO_PUBLICITY,
                StateForOrder.WAITING_FOR_ASSIGNED, OnOrOff.OFF, ExceptionIdentificationForOrder.NORMAL);
        int insert1 = orderFlagMapper.insert(orderFlag);
        ConcurrentHashMap resultMap  = new ConcurrentHashMap();
        if (insert!=0 && insert1!=0){
            resultMap.put("message","添加信息公示成功！");
        }

        else{
            resultMap.put("message","添加信息公示失败");
        }
        return  resultMap;
    }
    /**
     * end-lzh
     */

    /**
     * start-hwf
     */
    /**
     * end-hwf
     */
}
